var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		id : 'paging',
		l_column : [ {
			colkey : "name",
			name : "菜单名",
		}, {
			colkey : "resUrl",
			name : "菜单链接"
		},{
			colkey : "rootPhrase",
			name : "用户权限",
			width : "150px"
		}],
		jsonUrl : rootPath + '/menu/list.json',
		checkbox : true,
		serNumber : true
	});
});


function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "编辑",
		type : 2,
		area : [ "600px", "80%" ],
		content : rootPath + '/menu/edit.html?id=' + cbox
	});
}
function addAccount() {
	pageii = layer.open({
		title : "菜单新增",
		type : 2,
		area : [ "600px", "80%" ],
		content : rootPath + '/menu/add.html'
	});
}
function delAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择删除项！！");
		return;
	}
	layer.confirm('是否删除？', function(index) {
		var url = rootPath + '/menu/delete.json';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('删除成功');
			grid.loadData();
		} else {
			layer.msg('删除失败');
		}
	});
}